#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    while (n--) {
        double st;
        string sex;
        cin >> sex >> st;
        double res = sex == "M" ? st / 1.09 : st * 1.09;
        printf("%.2lf\n", res);
    }
    
    return 0;
}